package com.example.yichuangyun.mvvm.ui.adapter;

import android.content.Context;
import android.text.Html;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.QuickViewHolder;
import com.example.yichuangyun.R;
import com.example.yichuangyun.model.company.IntellectualPropertyDataModel;
import com.example.yichuangyun.utils.CommonUtil;

import java.util.List;

public class PatentAdapter extends BaseQuickAdapter<IntellectualPropertyDataModel.IntellectualPropertyModel, QuickViewHolder> {

    private final Context context;

    public PatentAdapter(Context context, @NonNull List<? extends IntellectualPropertyDataModel.IntellectualPropertyModel> items) {
        super(items);
        this.context = context;
    }

    @Override
    protected void onBindViewHolder(@NonNull QuickViewHolder quickViewHolder, int i, @Nullable IntellectualPropertyDataModel.IntellectualPropertyModel model) {
        if (model != null) {
            quickViewHolder.setVisible(R.id.tv_text6, false);
            quickViewHolder.setText(R.id.tv_text1, Html.fromHtml(context.getString(R.string.patent_name, CommonUtil.setText3(model.getPatentName())), Html.FROM_HTML_MODE_LEGACY));
            quickViewHolder.setText(R.id.tv_text2, Html.fromHtml(context.getString(R.string.patent_type, CommonUtil.setText3(model.getTypeName())), Html.FROM_HTML_MODE_LEGACY));
            quickViewHolder.setText(R.id.tv_text3, Html.fromHtml(context.getString(R.string.patent_auth_status, CommonUtil.setText3(model.getAuthorizeTag())), Html.FROM_HTML_MODE_LEGACY));
            quickViewHolder.setText(R.id.tv_text4, Html.fromHtml(context.getString(R.string.patent_apply_no, CommonUtil.setText3(model.getRequestNumStandard())), Html.FROM_HTML_MODE_LEGACY));
            quickViewHolder.setText(R.id.tv_text5, Html.fromHtml(context.getString(R.string.patent_apply_date, CommonUtil.setText3(model.getRequestDate())), Html.FROM_HTML_MODE_LEGACY));
        }
    }

    @NonNull
    @Override
    protected QuickViewHolder onCreateViewHolder(@NonNull Context context, @NonNull ViewGroup viewGroup, int i) {
        return new QuickViewHolder(R.layout.item_risk_child, viewGroup);
    }
}
